<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //求幂
        function callPower(m, n) {
            var power = 1;
            if (n == 0) return 1;
            else if (m == 0) return 0;
            var handstand = false;
            if (n < 0) {
                handstand = !handstand;
                n = (-n);
            }
            for (var i = 0; i < n; i++) {
                power *= m;
            }
            if (!handstand) return power;
            else return 1 / power;
        }
        //处理水仙花数条件,[整数]
        function callFinally(math) {
            var cat = String(math);
            var all = 0;
            for (var i = 0; i < cat.length; i++) {
                all += callPower(cat[i], cat.length);
            }
            return all === math ? all : false;
        }
        var start = +prompt("嘿,我的智商可以算出水仙花数了,请给我一个起点和终点,我能把它们之间的全部水仙花数捞出来,现在,请输入起点");
        var end = +prompt("那么终点是什么");
        console.log("那么" + start + "到" + end + "的水仙花数有:");
        var all = '';
        for (var i = start; i <= end; i++) {
            if (callFinally(i)) {
                all += i + " ";
            }
        }
        console.log(all);
    </script>
</body>

</html>